<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  

  
  <title>组件_处理边界情况 | Hexo</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description" content="组件_处理边界情况组件处理边界情况有一些相关的功能，即对Vue的规则做一些小调整的特殊情况。要注意的是这些功能都是有劣势和危险的场景的。">
<meta property="og:type" content="article">
<meta property="og:title" content="组件_处理边界情况">
<meta property="og:url" content="http://yoursite.com/2020/06/28/%E7%BB%84%E4%BB%B6_%E5%A4%84%E7%90%86%E8%BE%B9%E7%95%8C%E6%83%85%E5%86%B5/index.html">
<meta property="og:site_name" content="Hexo">
<meta property="og:description" content="组件_处理边界情况组件处理边界情况有一些相关的功能，即对Vue的规则做一些小调整的特殊情况。要注意的是这些功能都是有劣势和危险的场景的。">
<meta property="og:locale" content="en_US">
<meta property="article:published_time" content="2020-06-28T14:55:22.000Z">
<meta property="article:modified_time" content="2020-07-30T13:04:01.667Z">
<meta property="article:author" content="John Doe">
<meta property="article:tag" content="Vue">
<meta name="twitter:card" content="summary">
  
    <link rel="alternate" href="/atom.xml" title="Hexo" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png">
  
  
    <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  
  
<link rel="stylesheet" href="/css/style.css">

<meta name="generator" content="Hexo 5.0.0"></head>

<body>
  <div id="container">
    <div id="wrap">
      <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="/" id="logo">Hexo</a>
      </h1>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="/">Home</a>
        
          <a class="main-nav-link" href="/archives">Archives</a>
        
      </nav>
      <nav id="sub-nav">
        
          <a id="nav-rss-link" class="nav-icon" href="/atom.xml" title="RSS Feed"></a>
        
        <a id="nav-search-btn" class="nav-icon" title="Search"></a>
      </nav>
      <div id="search-form-wrap">
        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit">&#xF002;</button><input type="hidden" name="sitesearch" value="http://yoursite.com"></form>
      </div>
    </div>
  </div>
</header>
      <div class="outer">
        <section id="main"><article id="post-组件_处理边界情况" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2020/06/28/%E7%BB%84%E4%BB%B6_%E5%A4%84%E7%90%86%E8%BE%B9%E7%95%8C%E6%83%85%E5%86%B5/" class="article-date">
  <time datetime="2020-06-28T14:55:22.000Z" itemprop="datePublished">2020-06-28</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      组件_处理边界情况
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h4 id="组件-处理边界情况"><a href="#组件-处理边界情况" class="headerlink" title="组件_处理边界情况"></a>组件_处理边界情况</h4><p>组件处理边界情况有一些相关的功能，即对Vue的规则做一些小调整的特殊情况。要注意的是这些功能都是有劣势和危险的场景的。</p>
<a id="more"></a>
<h5 id="访问元素-amp-组件"><a href="#访问元素-amp-组件" class="headerlink" title="访问元素&amp;组件"></a>访问元素&amp;组件</h5><p>在绝大多数情况下，我们最好不要触达另一个组件的实例内部或手动操作Dom（Vue都是数据驱动试图的）。不过在一些特殊的情况下做这些也是合适的。</p>
<h5 id="访问根实例"><a href="#访问根实例" class="headerlink" title="访问根实例"></a>访问根实例</h5><p>在每个子组件，可以通过$rout访问根实例。</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">div</span> <span class="attr">id</span>=<span class="string">&quot;app&quot;</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">my-cmp</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">cmp-a</span>&gt;</span></span><br><span class="line">            <span class="tag">&lt;<span class="name">cmp-b</span>&gt;</span><span class="tag">&lt;/<span class="name">cmp-b</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;/<span class="name">cmp-a</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">my-cmp</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br></pre></td></tr></table></figure>
<p>所有的子组件都可以通过$root访问根元素组件（大型项目不要使用）</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br></pre></td><td class="code"><pre><span class="line">Vue.component(<span class="string">&#x27;my-cmp&#x27;</span>, &#123;</span><br><span class="line">    data()&#123;</span><br><span class="line">        <span class="keyword">return</span>&#123;</span><br><span class="line">            share:<span class="string">&#x27;share&#x27;</span></span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    template: <span class="string">&#x27;&lt;div&gt;&lt;slot&gt;&lt;/slot&gt;&lt;/div&gt;&#x27;</span></span><br><span class="line">&#125;)</span><br><span class="line">Vue.component(<span class="string">&#x27;cmp-a&#x27;</span>, &#123;</span><br><span class="line">    mounted()&#123;</span><br><span class="line">        <span class="built_in">console</span>.log(<span class="built_in">this</span>.$parent.share); <span class="comment">//打印出父组件 share</span></span><br><span class="line">    &#125;</span><br><span class="line">    template: <span class="string">&#x27;&lt;div&gt;&lt;slot&gt;&lt;/slot&gt;&lt;/div&gt;&#x27;</span></span><br><span class="line">&#125;)</span><br><span class="line">Vue.component(<span class="string">&#x27;cmp-b&#x27;</span>, &#123;</span><br><span class="line">    mounted()&#123;</span><br><span class="line">        <span class="built_in">console</span>.log(<span class="built_in">this</span>.$parent.$parent.share); <span class="comment">//打印 爷爷组件 share</span></span><br><span class="line">        <span class="built_in">console</span>.log(<span class="built_in">this</span>.$root.name); <span class="comment">//打印出根实例 name：zhu，尽量不要使用，因为不知道name 的数据在哪个组件会被更改</span></span><br><span class="line">    &#125;</span><br><span class="line">    template: <span class="string">&#x27;&lt;div&gt;&lt;slot&gt;&lt;/slot&gt;&lt;/div&gt;&#x27;</span></span><br><span class="line">&#125;)</span><br><span class="line"><span class="keyword">const</span> vm = <span class="keyword">new</span> Vue(&#123;</span><br><span class="line">    data: &#123;</span><br><span class="line">        name:<span class="string">&#x27;zhu&#x27;</span>,</span><br><span class="line">    &#125;,</span><br><span class="line"></span><br><span class="line">&#125;)</span><br></pre></td></tr></table></figure>
<p>若my-cmp需要共享一个属性share，它的所有子组件元素都需要访问share属性，在这种情况下cmp-a可以通过this.$parent.share的方式访问share。<br>那么通过这种方式构建出来的组件内部仍然容易出现问题。比如，在cmp-b组件中去访问share时，需要查看一下，其父组件是否存在share，如果不存在，则向上一级查找，落实到代码上为:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">var share &#x3D; this.$parent.share || this.$parent.$parent.share;</span><br></pre></td></tr></table></figure>
<p>如果这样做组件就会失控：触达父级组件会使用更难调解，尤其是当变更父组件数据时，过一段时间，很难找出变更是从哪里发起的。<br>碰到以上情况，可以使用依赖注入。</p>
<h5 id="依赖注入"><a href="#依赖注入" class="headerlink" title="依赖注入"></a>依赖注入</h5><p>在上面的例子中，利用$parent属性，没有办法很好的扩展到更深层级的嵌套组件上。这也是依赖注入的用武之地，这里用到了新的实例选项：provide和inject。<br>provide选项允许我们指定想要提供给后代组件的数据/方法,例如:</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">Vue.component(<span class="string">&#x27;cmp-parent&#x27;</span>,&#123;</span><br><span class="line">    provide ()&#123;</span><br><span class="line">        <span class="keyword">return</span> &#123;</span><br><span class="line">            share:<span class="built_in">this</span>.share</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;,</span><br><span class="line">    data ()&#123;</span><br><span class="line">        <span class="keyword">return</span>&#123;</span><br><span class="line">            share:<span class="string">&#x27;share&#x27;</span></span><br><span class="line">        &#125;</span><br><span class="line">    &#125;,</span><br><span class="line">    template:<span class="string">`&lt;div&gt;cmp-parent&lt;/div&gt;`</span></span><br><span class="line">&#125;)</span><br></pre></td></tr></table></figure>
<p>然后在任何后代组件中，都可以使用inject选项来接受指定想要添加在实例上的属性。</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">Vue.compontent(<span class="string">&#x27;cmp-a&#x27;</span>,&#123;</span><br><span class="line">    inject:[<span class="string">&#x27;share&#x27;</span>],</span><br><span class="line">    mounted ()&#123;</span><br><span class="line">        <span class="built_in">console</span>.log(<span class="built_in">this</span>.share); <span class="comment">//打印出注入的share</span></span><br><span class="line">    &#125;</span><br><span class="line">    template:<span class="string">`&lt;div&gt;cmp-a&lt;/div&gt;`</span></span><br><span class="line">&#125;)</span><br></pre></td></tr></table></figure>
<p>相比$parent来说，这个用法可以让我们在任意后代组件中访问share，而不是暴露整个cmp-parent实例。这允许我们更好的持续研发该组件，而不需要担心我们可能会改变/移除一些依赖的东西。同时这些组件之间的接口是始终明确定义的，就和prop一样。<br>实际上，可以把依赖注入看作一大部分“大范围的prop”，除了“：</p>
<ul>
<li>祖先组件不需要知道哪些后代元素使用他提供的组件</li>
<li>后代组件不需要知道被注入的属性来自哪里<br>但是，依赖注入也有负面的影响。它将你应用程序中的组件与它们当前的组织耦合起来，使重构更加困难。同时所提供的属性是非响应式的。因为使用它们来创建一个中心化规模化的数据跟使用$root做这些都是不够好的。如果你想要共享的这个属性是你的应用特有的，而不是通用化的，或者如果你想在祖先元素更新所提供的数据，那么这意味着你可能需要换用一个像Vuex这样真正的状态管理方式了。<h5 id="访问子组件实例或子元素"><a href="#访问子组件实例或子元素" class="headerlink" title="访问子组件实例或子元素"></a>访问子组件实例或子元素</h5>尽管存在prop和事件，但是有时候我们仍可以需要在js里直接访问一个子组件，那么此时可以通过ref特性为子组件赋予一个ID引用。<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">my-cmp</span> <span class="attr">ref</span>=<span class="string">&quot;cmp&quot;</span>&gt;</span><span class="tag">&lt;/<span class="name">my-cmp</span>&gt;</span></span><br></pre></td></tr></table></figure>
这样就可以通过this.$refs.cmp来访问<code>&lt;my—cmp&gt;</code>实例。<br>ref也可以对指定Dom元素进行访问，如:<figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">input</span> <span class="attr">ref</span>=<span class="string">&quot;input&quot;</span> /&gt;</span></span><br></pre></td></tr></table></figure>
那么可以通过this.$refs.input来访问Dom元素。<br>当ref和v-for一起使用时，得到的引用将会是一个包含了对应数据源的这些子组件的数组。<br>注意: $refs只会在组件渲染完成之后生效，并且不是响应式的。应该避免在模板或计算属性中访问$refs。<h5 id="程序化的事件侦听器"><a href="#程序化的事件侦听器" class="headerlink" title="程序化的事件侦听器"></a>程序化的事件侦听器</h5>除了v-on和$emit外，Vue实例在其事件接口中还提供了其他的方法。</li>
<li>$on(eventName,eventHandler)侦听一个事件</li>
<li>$once(eventName,eventHandler)一次性侦听一个事件</li>
<li>$off(eventName,eventHandler)停止侦听一个事件<br>这些方法一般不会被用到，但是，当需要在一个组件实例上手动侦听事件时，他们可以派得上用场。<br>例如:当使用第三方的库：<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line">Vue.component(<span class="string">&#x27;my-cmp&#x27;</span>,&#123;</span><br><span class="line">    <span class="comment">//一次性将这个日期选择器附加到一个输入框上</span></span><br><span class="line">    <span class="comment">//它会挂载到Dom上。</span></span><br><span class="line">     mounted()&#123;</span><br><span class="line">    <span class="built_in">this</span>.picker  = <span class="keyword">new</span> Pikaday(&#123;</span><br><span class="line">        field:<span class="built_in">this</span>.$refs.input;</span><br><span class="line">        format:<span class="string">&#x27;YYYY-MM-DD&#x27;</span></span><br><span class="line">    &#125;),</span><br><span class="line">    beforeDestory ()&#123;</span><br><span class="line">        <span class="built_in">this</span>.picked.destory();</span><br><span class="line">    &#125;,</span><br><span class="line">    template:<span class="string">`</span></span><br><span class="line"><span class="string">    &lt;div&gt;</span></span><br><span class="line"><span class="string">     &lt;input type=&quot;text&quot; ref=&quot;input&quot; /&gt;</span></span><br><span class="line"><span class="string">     &lt;button @click=&quot;$destory()&quot;&gt;销毁组件</span></span><br><span class="line"><span class="string">    &lt;/div&gt;</span></span><br><span class="line"><span class="string">    `</span></span><br><span class="line">     &#125;</span><br><span class="line">&#125;)</span><br></pre></td></tr></table></figure>
使用上面的方法，有两个潜在的问题：</li>
<li>它需要在这个组件实例上保存这个picker，如果可以的话只有生命周期钩子函数可以访问到它。这并不算严重的问题，但是它可以被视为杂物。</li>
<li>我们建立的代码独立于我们的清理代码，这使得我比较难于程序化地清理我们建立的所有东西。<br>所以，我们可以通过程序化的侦听器解决这两个问题：<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line">Vue.component(<span class="string">&#x27;my-cmp&#x27;</span>,&#123;</span><br><span class="line">   <span class="keyword">var</span> picker  = <span class="keyword">new</span> Pikaday(&#123;</span><br><span class="line">        field:<span class="built_in">this</span>.$refs.input;</span><br><span class="line">        format:<span class="string">&#x27;YYYY-MM-DD&#x27;</span></span><br><span class="line">    &#125;),</span><br><span class="line">    <span class="built_in">this</span>.$once(<span class="string">&#x27;hook:beforeDestory&#x27;</span>,<span class="function">()=&gt;</span>&#123;</span><br><span class="line">        picker.destory();</span><br><span class="line">    &#125;)</span><br><span class="line">     &#125;</span><br><span class="line">    template:<span class="string">`</span></span><br><span class="line"><span class="string">    &lt;div&gt;</span></span><br><span class="line"><span class="string">     &lt;input type=&quot;text&quot; ref=&quot;input&quot; /&gt;</span></span><br><span class="line"><span class="string">     &lt;button @click=&quot;$destory()&quot;&gt;销毁组件</span></span><br><span class="line"><span class="string">    &lt;/div&gt;</span></span><br><span class="line"><span class="string">    `</span></span><br><span class="line">     &#125;</span><br><span class="line">&#125;)</span><br></pre></td></tr></table></figure>
使用了这个策略 ，还可以让多个输入框使用不同的picker；<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><span class="line">Vue.component(<span class="string">&#x27;my-cmp&#x27;</span>, &#123;</span><br><span class="line"></span><br><span class="line">          mounted() &#123;</span><br><span class="line">              <span class="built_in">this</span>.dataPicker(<span class="string">&#x27;input1&#x27;</span>);</span><br><span class="line">              <span class="built_in">this</span>.dataPicker(<span class="string">&#x27;input2&#x27;</span>);</span><br><span class="line"></span><br><span class="line">          &#125;,</span><br><span class="line">          methods: &#123;</span><br><span class="line">              dataPicker(refName) &#123;</span><br><span class="line">                  <span class="keyword">var</span> picker = <span class="keyword">new</span> Pikaday(&#123;</span><br><span class="line">                          field: <span class="built_in">this</span>.$refs.input;</span><br><span class="line">                          format: <span class="string">&#x27;YYYY-MM-DD&#x27;</span></span><br><span class="line">                      &#125;),</span><br><span class="line">                      <span class="built_in">this</span>.$once(<span class="string">&#x27;hook:beforeDestory&#x27;</span>, <span class="function">() =&gt;</span> &#123;</span><br><span class="line">                          picker.destory();</span><br><span class="line">                      &#125;)</span><br><span class="line">              &#125;</span><br><span class="line">          &#125;,</span><br><span class="line">          template: <span class="string">`</span></span><br><span class="line"><span class="string">       &lt;div&gt;</span></span><br><span class="line"><span class="string">         &lt;input type=&quot;text&quot; ref=&quot;input1&quot; /&gt;</span></span><br><span class="line"><span class="string">         &lt;input type=&quot;text&quot; ref=&quot;input2&quot; /&gt;</span></span><br><span class="line"><span class="string">        &lt;button @click=&quot;$destory()&quot;&gt;销毁组件</span></span><br><span class="line"><span class="string">     &lt;/div&gt;</span></span><br><span class="line"><span class="string">   `</span></span><br><span class="line">      &#125;)</span><br></pre></td></tr></table></figure>
注意:即便如此，如果你发现自己不得不在单个组件里做很多建立和清理的工作，最好的方式通常还是创建更多的模块化组件，在这个例子中，推荐一个可复用的<code>&lt;input-datapicker&gt;</code></li>
</ul>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2020/06/28/%E7%BB%84%E4%BB%B6_%E5%A4%84%E7%90%86%E8%BE%B9%E7%95%8C%E6%83%85%E5%86%B5/" data-id="ckd8udtc4000r9gt4aodbcyed" class="article-share-link">Share</a>
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Vue/" rel="tag">Vue</a></li></ul>

    </footer>
  </div>
  
    
<nav id="article-nav">
  
    <a href="/2020/07/04/$nextTick%E7%90%86%E8%A7%A3/" id="article-nav-newer" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Newer</strong>
      <div class="article-nav-title">
        
          $nextTick理解
        
      </div>
    </a>
  
  
    <a href="/2020/06/24/js%E5%9D%97%E7%BA%A7%E4%BD%9C%E7%94%A8%E5%9F%9F%E7%9A%84%E5%9D%91/" id="article-nav-older" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Older</strong>
      <div class="article-nav-title">js块级作用域的坑</div>
    </a>
  
</nav>

  
</article>

</section>
        
          <aside id="sidebar">
  
    

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Tags</h3>
    <div class="widget">
      <ul class="tag-list" itemprop="keywords"><li class="tag-list-item"><a class="tag-list-link" href="/tags/Vue/" rel="tag">Vue</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Vue%E5%85%A8%E5%AE%B6%E6%A1%B6/" rel="tag">Vue全家桶</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/js/" rel="tag">js</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/node/" rel="tag">node</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Tag Cloud</h3>
    <div class="widget tagcloud">
      <a href="/tags/Vue/" style="font-size: 20px;">Vue</a> <a href="/tags/Vue%E5%85%A8%E5%AE%B6%E6%A1%B6/" style="font-size: 10px;">Vue全家桶</a> <a href="/tags/js/" style="font-size: 15px;">js</a> <a href="/tags/node/" style="font-size: 10px;">node</a>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Archives</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2020/07/">July 2020</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2020/06/">June 2020</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Recent Posts</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/2020/07/30/hello-world/">我的第一章博客</a>
          </li>
        
          <li>
            <a href="/2020/07/25/%E5%8E%9F%E7%94%9FHttp%E5%AE%9E%E7%8E%B0cookie%E8%AE%BE%E7%BD%AE/">原生Http实现cookie设置</a>
          </li>
        
          <li>
            <a href="/2020/07/23/%E5%B0%81%E8%A3%85Vue%E7%BB%84%E4%BB%B6%E5%B0%86%E4%BB%BB%E6%84%8F%E5%90%8E%E7%BC%80%E6%96%87%E4%BB%B6%E7%9B%AE%E5%BD%95%E7%BB%9F%E4%B8%80%E5%85%A8%E9%83%A8%E5%BC%95%E5%85%A5%E5%88%B0%E5%BD%93%E5%89%8D%E6%96%87%E4%BB%B6/">封装Vue组件将任意后缀文件目录统一全部引入到当前文件</a>
          </li>
        
          <li>
            <a href="/2020/07/15/js%E4%B8%AD%E7%9A%84%E9%98%B2%E6%8A%96%E4%B8%8E%E8%8A%82%E6%B5%81/">js中的防抖与节流</a>
          </li>
        
          <li>
            <a href="/2020/07/07/%E6%89%8B%E5%8A%A8%E5%AE%9E%E7%8E%B0call%EF%BC%8Capply,bind/">手动实现call，apply,bind</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
        
      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      &copy; 2020 John Doe<br>
      Powered by <a href="http://hexo.io/" target="_blank">Hexo</a>
    </div>
  </div>
</footer>
    </div>
    <nav id="mobile-nav">
  
    <a href="/" class="mobile-nav-link">Home</a>
  
    <a href="/archives" class="mobile-nav-link">Archives</a>
  
</nav>
    

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>


  
<link rel="stylesheet" href="/fancybox/jquery.fancybox.css">

  
<script src="/fancybox/jquery.fancybox.pack.js"></script>




<script src="/js/script.js"></script>




  </div>
</body>
</html>